function xout=subsref(x,s)
  nx = size(x);
  sd = s;
  I = reshape(1:numel(x.v),size(x.v));
  I = subsref(I,s);
  switch s.type
    case '()'
      % xout.v = x.v(s.subs{:});
      xout.v = subsref(x.v,s);
      xout.d = x.d(I,:);
   otherwise
    error('wrong index type for_ deriv1');
  end
  
  if(nnz(xout.d)==0)
    xout = xout.v;
  else
    xout = class(xout,'deriv1s');
  end
  
